/*****************************************************************************************************************************
 * \file   : Sensor.c
 * \module : Sensor  
 * \brief  : Sensor module achive  
 * \project: 
 * \author :  SHB
 *============================================================================================================================
 *                                                   Revision control History
 *============================================================================================================================
 * V1.0.0: 2023-06-29: Initial Version
 *
 *
 *
 ****************************************************************************************************************************/

/*****************************************************************************************************************************
 * Other header files
 ****************************************************************************************************************************/
#include "Sensor.h"

/*****************************************************************************************************************************
 * Macro decalaration
 ****************************************************************************************************************************/


/*****************************************************************************************************************************
 * Enum decalaration
 ****************************************************************************************************************************/

/*****************************************************************************************************************************
 * typedef compound type decalaration
 ****************************************************************************************************************************/


/*****************************************************************************************************************************
 * Struct decalaration
 ****************************************************************************************************************************/

/*****************************************************************************************************************************
 * Local variables decalaration
 ****************************************************************************************************************************/

/*****************************************************************************************************************************
 * Global variables definition
 ****************************************************************************************************************************/


/*****************************************************************************************************************************
 * Static Local Function decalaration property
 ****************************************************************************************************************************/
/*!
 * \brief Sensor calculation function, read adc value and than transfer to phsical data.
 * \param[in] me Sensor type pointer
 * \return none
 * \note This is a dummy function interface, A sensor object must be achieve it.
 */
static void Sensor_Calc(Sensor *me);
/*!
 * \brief Sensor get sample raw value function, A adc value or anything else.
 * \param[in] me Sensor type pointer
 * \return sample raw value
 * \note This is a dummy function interface, A sensor object must be achieve it.
 */
static Sensor_DataType Sensor_GetSampleRaw(Sensor *me);
/*****************************************************************************************************************************
 * Function definition
 ****************************************************************************************************************************/
/*****************************************************************************************************************************
 ** Function Name         : Sensor_Ctor
 **
 ** Service ID            : 0x01
 **
 ** Description           : This is Constructor
 **
 ****************************************************************************************************************************/
void Sensor_Ctor(Sensor *me, Sensor_DataType defaultVal, uint32_t ChannelId, uint8_t fifoSize)
{
    Queue_Ctor(&me->super, fifoSize);
    me->PhysicVal              = defaultVal;
    me->SensorSampleChannel    = ChannelId;
    me->Sensor_CalcPtr         = Sensor_Calc;
	me->Sensor_GetSampleRawPtr = Sensor_GetSampleRaw;
}
/*****************************************************************************************************************************
 ** Function Name         : Sensor_Update
 **
 ** Service ID            : 0x02
 **
 ** Description           : This function update sample data in queue
 **
 ****************************************************************************************************************************/
void Sensor_Update(Sensor *me)
{
    Sensor_DataType LeRaw;
 
    LeRaw = me->Sensor_GetSampleRawPtr(me);

    if ( Queue_IsFull(&me->super) != 0 ) {
        (void)Queue_Pop(&me->super);
    }
    Queue_Push(&me->super, LeRaw);

    me->Sensor_CalcPtr(me);
}
/*****************************************************************************************************************************
 ** Function Name         : Sensor_Calc
 **
 ** Service ID            : 0x03
 **
 ** Description           : This function is dummy function.
 **
 ****************************************************************************************************************************/
static void Sensor_Calc(Sensor *me)
{
    (void)me;
}
/*****************************************************************************************************************************
 ** Function Name         : Sensor_GetSampleRaw
 **
 ** Service ID            : 0x04
 **
 ** Description           : This function is dummy function.
 **
 ****************************************************************************************************************************/
 static Sensor_DataType Sensor_GetSampleRaw(Sensor *me)
 {
 	(void)me;
	return (Sensor_DataType)0;
 }
/*****************************************************************************************************************************
 * End of file
 ****************************************************************************************************************************/

